package idv.loveloser.mobilemoodle;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ForumSubjectsAdapter extends BaseAdapter{
	private List<MdlForumDiscussions> subjects;
	private Context mContext;
	private LayoutInflater mInflater;
	public ForumSubjectsAdapter(Context context){
		this.mContext=context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return subjects.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ForumSubjectHolder holder =null;
		this.mInflater = LayoutInflater.from(mContext); 
		if (convertView == null) {
			holder=new ForumSubjectHolder();   
			convertView = mInflater.inflate(R.layout.forum_holder, null);
			holder.iconImageView = (ImageView) convertView.findViewById(R.id.forumImageView1);
			holder.subjectTextView = (TextView) convertView.findViewById(R.id.forumDescription);
			convertView.setTag(holder); 
		}else{
			holder = (ForumSubjectHolder)convertView.getTag(); 
		}
		holder.subjectTextView.setText(subjects.get(position).getName());
		return convertView;
	}
	public List<MdlForumDiscussions> getSubjects() {
		return subjects;
	}
	public void setSubjects(List<MdlForumDiscussions> subjects) {
		this.subjects = subjects;
	}

}
